#include "TFT_LCD.h"
#include "lcdfont.h"
void LCD_GPIO_INIT()
{
	rcu_periph_clock_enable(RCU_AF);
	AFIO_PCF0 = (AFIO_PCF0 & 0xF8FFFFFF) | 0x02000000;
	//	gpio_pin_remap_config(GPIO_SWJ_DISABLE_REMAP,ENABLE);
	rcu_periph_clock_enable(RCU_GPIOA);
	rcu_periph_clock_enable(RCU_GPIOC);
	rcu_periph_clock_enable(RCU_GPIOD);
	rcu_periph_clock_enable(RCU_GPIOE);
	gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_12 | GPIO_PIN_15);
	gpio_init(GPIOC, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10);
	gpio_init(GPIOD, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_ALL);
	gpio_init(GPIOE, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_15);

	gpio_bit_set(GPIOA, GPIO_PIN_12 | GPIO_PIN_15);
	gpio_bit_set(GPIOC, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12);
	gpio_bit_reset(GPIOD, GPIO_PIN_ALL);
	gpio_bit_reset(GPIOE, GPIO_PIN_15);
}

/*************************************************************************
**函数名称：void TFTLCD_SetCursor(uint16_t x, uint16_t y)
**函数描述:设置光标位置
**输入参数:
**输出参数：
*************************************************************************/
void TFTLCD_SetCursor(uint16_t x, uint16_t y)
{
	TFTLCD_WR_REG(0x2a);	// column address set
	TFTLCD_WR_DATA(x >> 8); // column address start
	TFTLCD_WR_DATA(x & 0xff);
	TFTLCD_WR_DATA((TFTLCD_W - 1) >> 8);
	TFTLCD_WR_DATA((TFTLCD_W - 1) & 0XFF); // column address end

	TFTLCD_WR_REG(0x2b);	// Row address set
	TFTLCD_WR_DATA(y >> 8); // Row address start
	TFTLCD_WR_DATA(y & 0xff);
	TFTLCD_WR_DATA((TFTLCD_H - 1) >> 8); // Row address end
	TFTLCD_WR_DATA((TFTLCD_H - 1) & 0XFF);
}
/*************************************************************************
**函数名称:void TFTLCD_WriteRAM_Prepare(void)
**函数描述:开始写GRAM
**输入参数:
**输出参数:
*************************************************************************/
void TFTLCD_WriteRAM_Prepare(void)
{
	TFTLCD_WR_REG(0X2C);
}
/*************************************************************************
**函数名称：void TFTLCD_Clear(uint16_t color)
**函数描述:清屏函数
**输入参数:color:要清屏的填充色
**输出参数：
*************************************************************************/
void TFTLCD_Clear(uint16_t color)
{
	uint32_t index = 0;
	uint32_t totalpoint = TFTLCD_W;
	totalpoint *= TFTLCD_H;	   //得到总点数
	TFTLCD_SetCursor(0, 0);	   //设置光标位置
	TFTLCD_WriteRAM_Prepare(); //开始写入GRAM

	LCD_CS_CLR;

	LCD_RS_SET;
	for (index = 0; index < totalpoint; index++)
	{
		DATAOUT(color);
		LCD_WR_CLR;
		__NOP();
		LCD_WR_SET;
	}

	LCD_CS_SET;
}

void TFTLCD_Init(void)
{

	LCD_OFF(); //先关闭LCD显示
	LCD_CS_CLR;

	LCD_RST_SET;
	delay_1ms(1);
	LCD_RST_CLR;
	delay_1ms(10);
	LCD_RST_SET;
	delay_1ms(120);

	TFTLCD_WR_REG(0x28); // Display off

	// LCD_WR_REG(0x01); //Software reset

	TFTLCD_WR_REG(0x11); // sleep out
	delay_1ms(120);

	// LCD_WR_REG(0x13); //partial off

	// LCD_WR_REG(0x20); //display inversion off

	TFTLCD_WR_REG(0x36); // Memory data access control//方向
	TFTLCD_WR_DATA(0xA0);

	TFTLCD_WR_REG(0x3a);  // Interface pixel format
	TFTLCD_WR_DATA(0x55); // 65K RGB interface,16bit/pixel

	TFTLCD_WR_REG(0xb2); // Porch contol
	TFTLCD_WR_DATA(0x0c);
	TFTLCD_WR_DATA(0x0c);
	TFTLCD_WR_DATA(0x00);
	TFTLCD_WR_DATA(0x33);
	TFTLCD_WR_DATA(0x33);

	TFTLCD_WR_REG(0xb7);  // Gate control
	TFTLCD_WR_DATA(0x35); // VGH=13.26V;VGL=-10.43V;

	TFTLCD_WR_REG(0xbb);  // VCOM setting
	TFTLCD_WR_DATA(0x19); // VCOM=0.725V;

	TFTLCD_WR_REG(0xc0); // LCM control
	TFTLCD_WR_DATA(0x2c);

	TFTLCD_WR_REG(0xc2); // VDV and VRH command enable
	TFTLCD_WR_DATA(0x01);
	// LCD_WR_DATA(0xff);

	TFTLCD_WR_REG(0xc3); // VRH set ????
	TFTLCD_WR_DATA(0x12);

	TFTLCD_WR_REG(0xc4); // VDV setting
	TFTLCD_WR_DATA(0x20);

	TFTLCD_WR_REG(0xc6); // FR control 2
	TFTLCD_WR_DATA(0x0f);

	TFTLCD_WR_REG(0xca); //
	TFTLCD_WR_DATA(0x0f);

	TFTLCD_WR_REG(0xc8); //
	TFTLCD_WR_DATA(0x08);

	TFTLCD_WR_REG(0x55); //
	TFTLCD_WR_DATA(0x90);

	TFTLCD_WR_REG(0xd0); // Power control 1
	TFTLCD_WR_DATA(0xa4);
	TFTLCD_WR_DATA(0xa1);

	TFTLCD_WR_REG(0xe0); // Positive voltage gamma control
	TFTLCD_WR_DATA(0xd0);
	TFTLCD_WR_DATA(0x04);
	TFTLCD_WR_DATA(0x0d);
	TFTLCD_WR_DATA(0x11);
	TFTLCD_WR_DATA(0x13);
	TFTLCD_WR_DATA(0x2b);
	TFTLCD_WR_DATA(0x3f);
	TFTLCD_WR_DATA(0x54);
	TFTLCD_WR_DATA(0x4c);
	TFTLCD_WR_DATA(0x18);
	TFTLCD_WR_DATA(0x0d);
	TFTLCD_WR_DATA(0x0b);
	TFTLCD_WR_DATA(0x1f);
	TFTLCD_WR_DATA(0x23);

	TFTLCD_WR_REG(0xe1); // Negative voltage gamma control
	TFTLCD_WR_DATA(0xd0);
	TFTLCD_WR_DATA(0x04);
	TFTLCD_WR_DATA(0x0c);
	TFTLCD_WR_DATA(0x11);
	TFTLCD_WR_DATA(0x13);
	TFTLCD_WR_DATA(0x2c);
	TFTLCD_WR_DATA(0x3f);
	TFTLCD_WR_DATA(0x44);
	TFTLCD_WR_DATA(0x51);
	TFTLCD_WR_DATA(0x2f);
	TFTLCD_WR_DATA(0x1f);
	TFTLCD_WR_DATA(0x1f);
	TFTLCD_WR_DATA(0x20);
	TFTLCD_WR_DATA(0x23);

	TFTLCD_WR_REG(0x2a);  // column address set
	TFTLCD_WR_DATA(0x00); // column address start
	TFTLCD_WR_DATA(0x00);
	TFTLCD_WR_DATA(0x00);
	TFTLCD_WR_DATA(0xEf); // column address end

	TFTLCD_WR_REG(0x2b);  // Row address set
	TFTLCD_WR_DATA(0x00); // Row address start
	TFTLCD_WR_DATA(0x00);
	TFTLCD_WR_DATA(0x01); // Row address end
	TFTLCD_WR_DATA(0x3f);

	TFTLCD_WR_REG(0x29); // Display on

	TFTLCD_WR_REG(0x2c);

	TFTLCD_Clear(BLACK);

	delay_1ms(20); //为了使开机的时候不会产生雪花，故在刷屏后必须等待至少20ms

   LCD_ON();//显示屏点亮
}

/*************************************************************************
**函数名称：void TFTLCD_DrawPoint(uint16_t x, uint16_t y, uint32_t color)
**函数描述:画点函数
**输入参数：
**输出参数：
*************************************************************************/
void TFTLCD_DrawPoint(uint16_t x, uint16_t y, uint32_t color)
{
	TFTLCD_WR_REG(0x2a);	// column address set
	TFTLCD_WR_DATA(x >> 8); // column address start
	TFTLCD_WR_DATA(x & 0xff);

	TFTLCD_WR_REG(0x2b);	// Row address set
	TFTLCD_WR_DATA(y >> 8); // Row address start
	TFTLCD_WR_DATA(y & 0xff);

	TFTLCD_WR_REG(0X2C);
	TFTLCD_WR_DATA(color);

	TFTLCD_SetCursor(x, y);	   //设置光标位置
	TFTLCD_WriteRAM_Prepare(); //开始写入GRAM
	TFTLCD_WR_DATA(color);
}
/*************************************************************************
**函数名称：void TFTLCD_Fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t color)
**函数描述:在指定区域内填充单个颜色
**输入参数：(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
**输出参数：
*************************************************************************/
void TFTLCD_Fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t color)
{
	uint16_t i, j;
	uint16_t xlen = 0;
	xlen = ex - sx + 1;

	for (i = sy; i <= ey; i++)
	{
		TFTLCD_SetCursor(sx, i);   //设置光标位置
		TFTLCD_WriteRAM_Prepare(); //开始写入GRAM
		for (j = 0; j < xlen; j++)
			TFTLCD_WR_DATA(color); //显示颜色
	}
}
/*************************************************************************
**函数名称：void TFTLCD_SetWindow(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
**函数描述:设置屏幕窗口大小
**输入参数:
**输出参数：
*************************************************************************/
void TFTLCD_SetWindow(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
{
	TFTLCD_WR_REG(0x2a);	// column address set
	TFTLCD_WR_DATA(x >> 8); // column address start
	TFTLCD_WR_DATA(x & 0xff);
	TFTLCD_WR_DATA((x + width - 1) >> 8);
	TFTLCD_WR_DATA((x + width - 1) & 0xff); // column address end

	TFTLCD_WR_REG(0x2b);	// Row address set
	TFTLCD_WR_DATA(y >> 8); // Row address start
	TFTLCD_WR_DATA(y & 0xff);
	TFTLCD_WR_DATA((y + height - 1) >> 8); // Row address end
	TFTLCD_WR_DATA((y + height - 1) & 0xff);
}
/*************************************************************************
**函数名称：void TFTLCD_ShowPicture(uint16_t x, uint16_t y,const uint8_t* Picture, uint16_t width, uint16_t height)
**函数描述:读取内部flash中的普通图片(未压缩图片)数据，并显示
**输入参数：
**输出参数：
*************************************************************************/
void TFTLCD_ShowPicture(uint16_t x, uint16_t y, const uint8_t *Picture, uint16_t width, uint16_t height)
{
	uint16_t i, j;
	uint32_t k = 0;
	TFTLCD_SetWindow(x, y, width, height);
	TFTLCD_WriteRAM_Prepare();	//开始写入GRAM
	for (i = 0; i < width; i++) //图片高度
	{
		for (j = 0; j < height; j++) //图片宽度
		{
			TFTLCD_WR_DATA(((uint16_t)(Picture[k + 1] << 8)) + Picture[k]);
			k += 2;
		}
	}
}
void Address_set(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
{
	TFTLCD_WR_REG(0x2A);
	TFTLCD_WR_DATA(x1 >> 8);
	TFTLCD_WR_DATA(x1);
	TFTLCD_WR_DATA(x2 >> 8);
	TFTLCD_WR_DATA(x2);

	TFTLCD_WR_REG(0x2B);
	TFTLCD_WR_DATA(y1 >> 8);
	TFTLCD_WR_DATA(y1);
	TFTLCD_WR_DATA(y2 >> 8);
	TFTLCD_WR_DATA(y2);
	TFTLCD_WR_REG(0x2c);
}

//画线
// x1,y1:起点坐标
// x2,y2:终点坐标
void LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color, uint8_t crude)
{
	uint8_t i;
	uint16_t t;
	int xerr = 0, yerr = 0, delta_x, delta_y, distance;
	int incx, incy, uRow, uCol;
	for (i = 0; i < crude; i++)
	{
		delta_x = (x2 + i) - (x1 + i); //计算坐标增量
		delta_y = y2 - y1;
		uRow = (x1 + i);
		uCol = y1;
		if (delta_x > 0)
			incx = 1; //设置单步方向
		else if (delta_x == 0)
			incx = 0; //垂直线
		else
		{
			incx = -1;
			delta_x = -delta_x;
		}
		if (delta_y > 0)
			incy = 1;
		else if (delta_y == 0)
			incy = 0; //水平线
		else
		{
			incy = -1;
			delta_y = -delta_y;
		}
		if (delta_x > delta_y)
			distance = delta_x; //选取基本增量坐标轴
		else
			distance = delta_y;
		for (t = 0; t <= distance + 1; t++) //画线输出
		{
			TFTLCD_DrawPoint(uRow, uCol, color); //画点
			xerr += delta_x;
			yerr += delta_y;
			if (xerr > distance)
			{
				xerr -= distance;
				uRow += incx;
			}
			if (yerr > distance)
			{
				yerr -= distance;
				uCol += incy;
			}
		}
	}
}
//---------------------------------
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color)
{
	int16_t i, j, width, height;
	width = x2 - x1;
	height = y2 - y1;
	if (width > 0 && height > 0)
	{
		TFTLCD_SetWindow(x1, y1, width, height);
		TFTLCD_WriteRAM_Prepare();	//开始写入GRAM
		for (i = 0; i < width; i++) //图片高度
		{
			for (j = 0; j < height; j++) //图片宽度
			{
				TFTLCD_WR_DATA(color);
			}
		}
	}
}

uint16_t Color_Transparent(uint16_t color, uint16_t back_color, uint8_t percent)
{
	// uint16_t color_buff[6] = {[0 ... 5] = 0};	//报错
	uint16_t color_buff[6] = {0};
	uint8_t i;
	color_buff[0] = (color >> 11);
	color_buff[1] = ((color >> 5) & 0X3F);
	color_buff[2] = (color & 0X1F);
	color_buff[3] = (back_color >> 11);
	color_buff[4] = ((back_color >> 5) & 0X3F);
	color_buff[5] = (back_color & 0X1F);
	for (i = 0; i < 3; i++)
	{
		color_buff[i] = (color_buff[i] * percent + color_buff[i + 3] * (0x0f - percent)) >> 4;
	}
	return ((color_buff[0] << 11) + (color_buff[1] << 5) + color_buff[2]);
}

uint16_t TFTLCD_Char(uint16_t x, uint16_t y, uint16_t For_color, uint16_t Bk_color, uint8_t num, const type_font *font)
{
	uint8_t i;
	uint16_t color[2];								   //字符数组每个字节高位和低位分别表示一个透明度
	uint16_t point_x = 0, point_y = 0;				   //光标的位置（当前正在打的点的位置坐标）
	int16_t x0 = 0, y0 = 0, x1 = 0, y1 = 0, width = 0; //背景以外需要打点的区域 / 字符的宽度
	uint32_t /*points_num = 0,*/ p_data_count = 0;	   //需要打的点总数 / 对应字符的数组的地址位
	const GUI_FONT_PROP_EXT *Prop = font->Prop;		   //配置当前表格为第一张查询表格
	const GUI_CHARINFO_EXT *Char_Info;				   //表格内当前字符的位置

	for (i = 0; i < font->Prop_Num; i++)
	{ //判断是否在当前表格范围内，如果不在范围内，则跳入下一个表格查找
		if (num >= Prop->First && num <= Prop->Last)
		{
			Char_Info = Prop->paCharInfo + +(num - Prop->First);
			break;
		}
		else
		{
			Prop = Prop->pNext;
		}
	}
	width = (Char_Info->XSize) > (Char_Info->XDist) ? (Char_Info->XSize) : (Char_Info->XDist); // Char_Info->XSize + 2 * (Char_Info->XPos>0);//整个需要打点区域的宽度
	x = x + (Char_Info->XPos) * (Char_Info->XPos < 0);										   //整个需要打点区域的起始X坐标
	x0 = (Char_Info->XPos) * (Char_Info->XPos >= 0);										   //字符区域的起始X坐标
	y0 = Char_Info->YPos;																	   //字符区域的起始Y坐标
	x1 = x0 + Char_Info->XSize;																   //字符区域的结束X坐标
	y1 = y0 + Char_Info->YSize;																   //字符区域的结束Y坐标
	Address_set(x, y, x + width - 1, y + font->YSize - 1);									   //设置字符显示的地址范围
	while (point_y < font->YSize)
	{
		if (point_x >= x0 && point_x < x1 && point_y >= y0 && point_y < y1)
		{
			color[0] = (*(Char_Info->pData + p_data_count)) >> 4;	//每个字节高低位代表2个颜色
			color[1] = (*(Char_Info->pData + p_data_count)) & 0X0F; //
			for (i = 0; i < 2; i++)
			{
				if (color[i])
				{
					TFTLCD_WR_DATA(Color_Transparent(For_color, Bk_color, color[i]));
				}
				else
				{
					TFTLCD_WR_DATA(Bk_color);
				}
				point_x++; //当前需要打的点的X坐标 往后加1
				if (point_x >= width)
				{
					point_x = 0;
					point_y++;
					break;
				} //当前需要打的点的X坐标一行打满后，Y坐标加1，X坐标清零；当字符宽度为奇数，每行最后一个字节只有高位的颜色数据有效
			}
			p_data_count++; //当前字符数组的指针加1
		}
		else
		{
			TFTLCD_WR_DATA(Bk_color);
			point_x++; //当前需要打的点的X坐标 往后加1
			if (point_x >= width)
			{
				point_x = 0;
				point_y++;
			} //当前需要打的点的X坐标一行打满后，Y坐标加1，X坐标清零；
		}
	}
	return (x + width);
}

uint16_t TFTLCD_Str(uint16_t x, uint16_t y, uint16_t For_color, uint16_t Bk_color, char *ch, const type_font *font)
{
	while ((*ch) != 0)
	{
		x = TFTLCD_Char(x, y, For_color, Bk_color, *ch, font);
		ch++;
	}
	return x;
}
/*************************************************************************
**函数名称：void TFTLCD_Draw_RLE_Bitmap(uint16_t x0, uint16_t y0,const GUI_BITMAP *Bitmap)
**函数描述:读取内部flash中的RLE图片(压缩图片)数据并显示
**输入参数：
**输出参数：
*************************************************************************/
void TFTLCD_Draw_RLE_Bitmap(uint16_t x0, uint16_t y0, const GUI_BITMAP *Bitmap)
{
	uint32_t NumByte_Has_Readed = 0, index_1 = 0, index_2 = 0, index_3 = 0;
	uint16_t Bitmap_Data = 0;
	uint32_t Size = Bitmap->XSize * Bitmap->YSize; // sizeof(Bitmap->P_Data);

	TFTLCD_SetWindow(x0, y0, Bitmap->XSize, Bitmap->YSize);
	TFTLCD_WriteRAM_Prepare(); //开始写入GRAM

	LCD_RS_SET;
	LCD_CS_CLR;

	while (Size) //数组的最后一个字节为必为0，这个字节没用，所以有效长度为Bitmap->Size-1
	{
		index_3 = NumByte_Has_Readed + 3;
		index_2 = NumByte_Has_Readed + 2;
		index_1 = NumByte_Has_Readed + 1;
		if (Bitmap->pData[NumByte_Has_Readed] != 0)
		{
			Bitmap_Data = ((uint16_t)Bitmap->pData[index_2] << 8) + Bitmap->pData[index_1];
			for (uint16_t i = 0; i < Bitmap->pData[NumByte_Has_Readed]; i++)
			{
				DATAOUT(Bitmap_Data);
				LCD_WR_CLR;
				LCD_WR_SET;
				Size--;
			}
			NumByte_Has_Readed += 3;
		}
		else
		{
			for (uint16_t i = 0; i < Bitmap->pData[index_1]; i++)
			{
				DATAOUT(((uint16_t)Bitmap->pData[index_3 + i + i] << 8) + Bitmap->pData[index_2 + i + i]);
				LCD_WR_CLR;
				LCD_WR_SET;
				Size--;
			}
			NumByte_Has_Readed += 2 + (Bitmap->pData[index_1] << 1);
		}
	}
	LCD_CS_SET;
}

/******************************************************************************
	  函数说明：显示单个24x24汉字
	  入口数据：x,y显示坐标
				*s 要显示的汉字
				fc 字的颜色
				bc 字的背景色
				sizey 字号
				mode:  0非叠加模式  1叠加模式
	  返回值：  无
******************************************************************************/
void LCD_ShowChinese16x16(uint16_t x, uint16_t y, uint8_t *s, uint16_t fc, uint16_t bc, uint8_t sizey, uint8_t mode)
{
	uint8_t i, j;
	uint16_t k;
	uint16_t HZnum;		  //汉字数目
	uint16_t TypefaceNum; //一个字符所占字节大小
	uint16_t x0 = x;
	TypefaceNum = sizey / 8 * sizey;			   //此算法只适用于字宽等于字高，且字高是8的倍数的字，
												   //也建议用户使用这样大小的字,否则显示容易出问题！
	HZnum = sizeof(tfont16) / sizeof(typFNT_GB16); //统计汉字数目
	for (k = 0; k < HZnum; k++)
	{
		if ((tfont16[k].Index[0] == *(s)) && (tfont16[k].Index[1] == *(s + 1)))
		{
			TFTLCD_SetWindow(x, y, sizey, sizey);
			TFTLCD_WriteRAM_Prepare();

			for (i = 0; i < TypefaceNum; i++)
			{
				for (j = 0; j < 8; j++)
				{
					if (!mode) //非叠加方式
					{
						if (tfont16[k].Msk[i] & (0x01 << j))
						{
							TFTLCD_WR_DATA(fc);
						}
						else
						{
							TFTLCD_WR_DATA(bc);
						}
					}
					else //叠加方式
					{
						if (tfont16[k].Msk[i] & (0x01 << j))
							TFTLCD_DrawPoint(x, y, fc); //画一个点
						x++;
						if ((x - x0) == sizey)
						{
							x = x0;
							y++;
							break;
						}
					}
				}
			}
		}
		continue; //查找到对应点阵字库立即退出，防止多个汉字重复取模带来影响
	}
}
/******************************************************************************
	  函数说明：显示汉字串
	  入口数据：x,y显示坐标
				*s 要显示的汉字串
				fc 字的颜色
				bc 字的背景色
				sizey 字号 可选 16 24 32
				mode:  0非叠加模式  1叠加模式
	  返回值：  无
******************************************************************************/
void LCD_ShowChinese(uint16_t x, uint16_t y, uint8_t *s, uint16_t fc, uint16_t bc, uint8_t sizey, uint8_t mode)
{
	while (*s != 0)
	{
		if (*s > 0x7e)
		{
			if (sizey == 16)
				LCD_ShowChinese16x16(x, y, s, fc, bc, sizey, mode);
			else
				return;
			s += 2;
			x += sizey;
		}
		else
		{
			//					TFTLCD_Char(x,y,fc,bc,' ',&Arial_18);
			//					s++;
			//					x+=4;
			x = TFTLCD_Char(x, y, fc, bc, *s, &Arial_18);
			s++;
		}
	}
}

void TimeStr_LCDClear(uint16_t x, uint16_t y, char Length)
{
	char Empty[32] = {0};
	for (uint16_t i = 0; i < Length; i++)
	{
		Empty[i] = ' ';
	}
	TFTLCD_Str(x, y, MY_BLUE, DISE, Empty, &Arial_18);
}


